﻿@model SCMS.UI.Models.RequestReviewModel
@{
    int numReview = 0;
    int procReview = 0;
    int finReview = 0;
    int totalNotif = 0;
    string notifClass = "";
    string notifTitle = "";
    string notifValue = "";
    procReview += Model.OrderRequests != null ? Model.OrderRequests.Count : 0;
    procReview += Model.TenderAnalyses != null ? Model.TenderAnalyses.Count : 0;
    procReview += Model.PurchaseOrders != null ? Model.PurchaseOrders.Count : 0;

    finReview += Model.PaymentRequests != null ? Model.PaymentRequests.Count : 0;

    numReview = procReview + finReview;

    int numAuth = 0;
    int procAuth = 0;
    int finAuth = 0;
    procAuth += Model.AuthOrderRequests != null ? Model.AuthOrderRequests.Count : 0;
    procAuth += Model.AuthTenderAnalyses != null ? Model.AuthTenderAnalyses.Count : 0;
    procAuth += Model.AuthPurchaseOrders != null ? Model.AuthPurchaseOrders.Count : 0;

    finAuth += Model.AuthPaymentRequests != null ? Model.AuthPaymentRequests.Count : 0;    

    numAuth = procAuth + finAuth;

    totalNotif = numReview + numAuth;
    if (totalNotif > 1)
    {
        notifClass = "notification noti-yellow";
        notifTitle = string.Format("You have {0} notifications", totalNotif);
        notifValue = totalNotif.ToString();
    }
    else if(totalNotif == 1)
    {
        notifClass = "notification noti-yellow";
        notifTitle = string.Format("You have {0} notification", totalNotif);
        notifValue = totalNotif.ToString();
    }
    else
    {
        notifClass = "notification noti-blue";
        notifTitle = "You have no notifications at this time";
        notifValue = "!";
    }
    
}
<div style="width:auto;">                    
    <dl class="dropdown" style="">
        <dt>
            <span id="linkglobal" class="@notifClass" title="@notifTitle">@notifValue</span>
        </dt>
        <dd>
            <ul id="noti-root" style="display: none;">
                <!-- Auth RFP -->
                @if (Model.AuthPaymentRequests != null && Model.AuthPaymentRequests.Count > 0)
                {
                    <li><b>Authorize RFP</b></li>
                    foreach (var rfp in Model.AuthPaymentRequests)
                    { 
                        <li>
                            @Ajax.ActionLink(rfp.EntityPaymentRqst.RefNumber, "../RequestReview/", new { id = "LoadRFPForAuth" }, new AjaxOptions
                            {
                                OnBegin = "ShowDialogueOR('Authorize Request For Payment: " + rfp.EntityPaymentRqst.RefNumber + "')",
                                UpdateTargetId = "popup-page",
                                LoadingElementId = "popup-loading",
                                Url = Url.Action("../RequestReview/LoadRFPForAuth/" + rfp.EntityPaymentRqst.Id),
                                OnSuccess = "CenterPopupRFP"
                            }, new { @class = "reviewLink" }) 
                        </li>
                    }
                } 

                <!-- Auth OR -->
                @if (Model.AuthOrderRequests != null && Model.AuthOrderRequests.Count > 0)
                {
                    <li><b>Authorize OR</b></li>
                    foreach (var or in Model.AuthOrderRequests)
                    { 
                        <li>
                            @Ajax.ActionLink(or.ORRefNo, "../RequestReview/", new { id = "LoadOrderRequestForAuth" }, new AjaxOptions
                       {
                           OnBegin = "ShowDialogueOR('Authorize Order Request: " + or.ORRefNo + "')",
                           UpdateTargetId = "popup-page",
                           LoadingElementId = "popup-loading",
                           Url = Url.Action("../RequestReview/LoadOrderRequestForAuth/" + or.ORID),
                           OnSuccess = "CenterPopupOR"
                       }, new { @class = "reviewLink" }) 
                        </li>
                    }
                }
                  
                <!-- Auth TA -->
                @if (Model.AuthTenderAnalyses != null && Model.AuthTenderAnalyses.Count > 0)
                {
                    <li><b>Authorize TA</b></li>
                    foreach (var ta in Model.AuthTenderAnalyses)
                    {
                        <li>
                            @Ajax.ActionLink(ta.EntityTenderAnalysis.RefNumber, "../RequestReview/", new { id = "LoadOrderRequest" }, new AjaxOptions
                       {
                           OnBegin = "ShowDialogueOR('Authorize Tender Analysis: " + ta.EntityTenderAnalysis.RefNumber + "')",
                           UpdateTargetId = "popup-page",
                           LoadingElementId = "popup-loading",
                           Url = Url.Action("../RequestReview/LoadOrderRequest/" + ta.EntityTenderAnalysis.Id),
                           OnSuccess = "CenterPopupOR"
                       }, new { @class = "reviewLink" }) 
                        </li>
                    }
                }                                   
                 
                <!-- Auth PO -->
                @if (Model.AuthPurchaseOrders != null && Model.AuthPurchaseOrders.Count > 0)
                {
                    <li><b>Authorize PO</b></li>
                    foreach (var po in Model.AuthPurchaseOrders)
                    {
                        <li>
                            @Ajax.ActionLink(po.POEntiy.RefNumber, "../RequestReview/", new { id = "LoadPurchaseOrderForAuth" }, new AjaxOptions
                       {
                           OnBegin = "ShowDialogueOR('Authorize Purchase Order: " + po.POEntiy.RefNumber + "')",
                           UpdateTargetId = "popup-page",
                           LoadingElementId = "popup-loading",
                           Url = Url.Action("../RequestReview/LoadPurchaseOrderForAuth/" + po.POEntiy.Id),
                           OnSuccess = "CenterPopupPO"
                       }, new { @class = "reviewLink" }) 
                        </li>
                    }
                } 

                <!-- Review RFP -->      
                @if (Model.PaymentRequests != null && Model.PaymentRequests.Count > 0)
                {
                    <li><b>Approve RFP</b></li>
                    foreach (var rfp in Model.PaymentRequests)
                    { 
                        <li>
                            @Ajax.ActionLink(rfp.EntityPaymentRqst.RefNumber, "../RequestReview/", new { id = "ReviewRFP" }, new AjaxOptions
                       {
                           OnBegin = "ShowDialogueOR('Review Request For Payment: " + rfp.EntityPaymentRqst.RefNumber + "')",
                           UpdateTargetId = "popup-page",
                           LoadingElementId = "popup-loading",
                           Url = Url.Action("../RequestReview/ReviewRFP/" + rfp.EntityPaymentRqst.Id),
                           OnSuccess = "CenterPopupRFP"
                       }, new { @class = "reviewLink" }) 
                        </li>
                    }
                }                        
                                
                <!-- Review OR -->
                @if (Model.OrderRequests != null && Model.OrderRequests.Count > 0)
                {
                    <li><b>Approve OR (@Model.OrderRequests.Count)</b>
                    <ul>
                    @foreach (var or in Model.OrderRequests)
                    { 
                        <li>
                            @Ajax.ActionLink(or.ORRefNo, "../RequestReview/", new { id = "LoadOrderRequest" }, new AjaxOptions
                       {
                           OnBegin = "ShowDialogueOR('Review Order Request: " + or.ORRefNo + "')",
                           UpdateTargetId = "popup-page",
                           LoadingElementId = "popup-loading",
                           Url = Url.Action("../RequestReview/LoadOrderRequest/" + or.ORID),
                           OnSuccess = "CenterPopupOR"
                       }, new { @class = "reviewLink" }) 
                        </li>
                    }
                    </ul>
                    </li>
                }
                
                <!-- Review TA -->
                @if (Model.TenderAnalyses != null && Model.TenderAnalyses.Count > 0)
                {
                    <li><b>Approve TA</b></li>
                    foreach (var ta in Model.TenderAnalyses)
                    {
                        <li>
                            @Ajax.ActionLink(ta.EntityTenderAnalysis.RefNumber, "../RequestReview/", new { id = "ReviewTA" }, new AjaxOptions
                       {
                           OnBegin = "ShowDialogueOR('Review Tender Analysis: " + ta.EntityTenderAnalysis.RefNumber + "')",
                           UpdateTargetId = "popup-page",
                           LoadingElementId = "popup-loading",
                           Url = Url.Action("../RequestReview/ReviewTA/" + ta.EntityTenderAnalysis.Id),
                           OnSuccess = "CenterPopup"
                       }, new { @class = "reviewLink" }) 
                        </li>
                    }
                }    

                <!-- Review PO -->
                @if (Model.PurchaseOrders != null && Model.PurchaseOrders.Count > 0)
                {
                    <li><b>Approve PO</b></li>
                    foreach (var po in Model.PurchaseOrders)
                    {
                        <li>
                            @Ajax.ActionLink(po.POEntiy.RefNumber, "../RequestReview/", new { id = "LoadPurchaseOrder" }, new AjaxOptions
                       {
                           OnBegin = "ShowDialogueOR('Review Purchase Order: " + po.POEntiy.RefNumber + "')",
                           UpdateTargetId = "popup-page",
                           LoadingElementId = "popup-loading",
                           Url = Url.Action("../RequestReview/LoadPurchaseOrder/" + po.POEntiy.Id),
                           OnSuccess = "CenterPopupPO"
                       }, new { @class = "reviewLink" }) 
                        </li>
                    }
                }         
            </ul>
        </dd>
    </dl>
</div>